On this page

Skip to content

On jQuery

TLDR

  • The necessity of jQuery in modern development has significantly decreased, as mainstream browsers have unified under W3C standards and native JavaScript APIs now cover most jQuery functionality.
  • jQuery lacks framework-level structural management, leading to high maintenance costs as project scale increases.
  • It is recommended to use Vue.js as an alternative to jQuery, as it supports progressive adoption without the immediate need to learn complex build tools.
  • If a project is highly dependent on .NET Model Validation, consider using Vue 2 with VeeValidate 2 as a transition, though long-term maintenance risks should be evaluated.
  • ASP.NET Core Blazor is a potential option for future transformation, suitable for teams that prefer to develop entirely in C#.

Technical Positioning and Current Status of jQuery

In modern Web development, the core value of jQuery has been gradually replaced by native technologies. The following is an analysis of its pros and cons in the current environment:

Browser Compatibility and the Evolution of Native APIs

  • When this issue arises: When developers are evaluating whether it is still necessary to include the jQuery library to handle cross-browser differences.
  • Analysis: In the early days, jQuery solved the syntax gaps between IE and other browsers and compensated for the scarcity of native DOM manipulation APIs. However, with IE exiting the market, mainstream browsers now follow W3C standards, and native JavaScript APIs (such as querySelector, etc.) can replace the vast majority of jQuery's selector and manipulation functions.
  • Conclusion: For new projects, including jQuery is no longer necessary; it is recommended to prioritize native JavaScript.

Structural and Maintainability Challenges

  • When this issue arises: When the project scale expands and developers begin to feel that the code logic is chaotic and difficult to manage.
  • Analysis: jQuery is essentially a library rather than a framework and lacks mandatory architectural specifications. This causes code quality to rely heavily on the developer's personal habits, and as features increase, it easily forms "spaghetti code" that is difficult to maintain.
  • Conclusion: If a project has a certain level of complexity, it should shift to a framework with Component-based capabilities to improve code maintainability.

Technical Selection Recommendations for Replacing jQuery

For .NET MVC or Razor Pages developers, if you wish to reduce reliance on jQuery, consider the following paths:

Choosing Vue.js as a Progressive Alternative

  • When this issue arises: When developers want to introduce a frontend framework but do not want to immediately invest in high learning costs (such as Webpack or the Node.js ecosystem).
  • Advantages: Vue.js supports direct inclusion via <script> tags and can be integrated into existing .NET projects in a progressive manner, enhancing interactivity only for specific screen sections.
  • Notes: The Composition API introduced in Vue 3 has a steeper learning curve for engineers accustomed to traditional development patterns. If you need to continue using .NET Model Validation mechanisms, some developers currently still choose to use Vue 2 with VeeValidate 2.

Choosing ASP.NET Core Blazor

  • When this issue arises: When developers want to completely avoid the JavaScript ecosystem and unify frontend and backend development using C#.
  • Advantages: Blazor allows the use of C# to build interactive UIs, which has a lower technical transfer cost for engineers with a .NET background.
  • Conclusion: If you cannot adapt to the rapid evolution of frontend frameworks in the future, or cannot find a suitable JavaScript validation package, shifting to Blazor will be a robust choice for long-term maintenance of .NET projects.

Change Log

  • 2022-09-30 Initial document creation.